home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d11 / viz412.arc / DOS_ENV.TXT < prev    next >
Text File  |  1991-06-06  |  8KB  |  149 lines

  1.  
  2.    THE DOS ENVIRONMENT BLOCK
  3.  
  4.    When the *initial* copy of COMMAND.COM is loaded at boot time, it creates a
  5.    block of memory that will contain the master or global DOS environment. The
  6.    environment of DOS consists of a number of text string variables maintained
  7.    by COMMAND.COM, each variable consisting of a name and an associated string
  8.    having the form
  9.  
  10.                              VARIABLE=string of characters
  11.     
  12.    in which the end of the string is indicated by a zero byte (ASCIIz string).
  13.    The environment usually contains a series of such variables, and the end of
  14.    the environment is indicated by an additional zero byte.  The variables are
  15.    used to pass information to and from the DOS shell COMMAND.COM, batch files
  16.    and, sometimes, application programs.
  17.  
  18.    Variables can be added to the DOS environment via the SET command.  Some of
  19.    these variables, however, are added without user intervention; for example,
  20.    after a hard-disk booting without an AUTOEXEC.BAT file, the DOS environment 
  21.    contains the following two variables:
  22.  
  23.                              PATH=
  24.                              COMSPEC=C:\COMMAND.COM
  25.  
  26.    The variable PATH= tells COMMAND.COM which directories to search for files,
  27.    whereas the variable COMSPEC= tells COMMAND.COM from where to reload itself
  28.    to replace its transient portion located in high RAM.  In addition to these
  29.    variables, other ones (such as PROMPT=) may be present; the contents of the
  30.    environment can be inspected by entering 'SET' from the DOS prompt line.
  31.  
  32.  
  33.  
  34.    GLOBAL vs. LOCAL ENVIRONMENT
  35.  
  36.    Each program loaded by COMMAND.COM, including any secondary copy of itself,
  37.    such as when running a batch file from another with the instruction:
  38.  
  39.                           [d:][\path]command /C xxxx.BAT
  40.  
  41.    inherits from the 'parent' a static copy of its environment block. Be aware
  42.    that the contents of the DOS environment of the 'child' are not transferred
  43.    or copied to the environment of the 'parent,' and that there is little room
  44.    in the inherited environment for addition or modification of variables.
  45.  
  46.    In setting up an environment variable for the software, especially when the
  47.    variable is being modified (rather than created), you should make sure that
  48.    the modification takes place in the global environment of DOS, and not of a
  49.    secondary command-processor copy, if you wish to preserve the modification.
  50.    Alternatively, running a batch file via a secondary copy of COMMAND.COM is
  51.    an excellent manner to use temporary variables or modifications that do not
  52.    need to be restored or removed at the end of the file.  Notice that the DOS
  53.    3.2+ command CALL, which can also be used to run a batch file from another,
  54.    preserves the environment of the 'child' batch file upon termination of the
  55.    'parent' file.
  56.  
  57.    Whereas the SET command modifies the current DOS environment block (whether
  58.    it is the global or a local one), switch /E only modifies the global block,
  59.    even when it is issued under a secondary copy of COMMAND.COM (in which case
  60.    the local environment is not changed).  /E access to the global environment
  61.    requires use of an undocumented DOS function (52h) which has been found not
  62.    to work in some buggy DOS 4.00 versions (but works in versions 2.10 through
  63.    3.31 and 4.01).
  64.  
  65.  
  66.  
  67.    ENVIRONMENT SIZE
  68.  
  69.    Depending on the DOS version, the environment's size may be up to 32 kbytes
  70.    (i.e. 32,768 decimal bytes) long.  The default environment size of COMMAND.
  71.    COM, however, is of 160 bytes in versions 2.2x through 3.3x; this space can
  72.    fill up quickly, in which case DOS displays the message 'Out of environment
  73.    space' when attempting to add a new variable or increasing an existing one.
  74.  
  75.    In DOS versions 3.10 and later, the size of the environment can be modified
  76.    by including the following statement in the CONFIG.SYS file:
  77.  
  78.                       SHELL=[d:][\path]COMMAND.COM /P /E:nn
  79.  
  80.    in which [d:] and [\path] are the drive and path specification, P indicates
  81.    that this is to be considered the initial loading of the command processor,
  82.    and /E:nn specifies the size of the environment in <nn> bytes (versions 3.2
  83.    and higher) or <nn> paragraphs (1 paragraph=16 bytes, version 3.1).  Notice
  84.    that version 3.1 allows a maximum environment of 992 bytes (62 paragraphs).
  85.  
  86.    For DOS versions 2.0 up to 3.0, however, the size of the environment can be
  87.    changed only by patching 1 or 2 bytes in the COMMAND.COM file. (This may be
  88.    done by using DEBUG as discussed below.)
  89.  
  90.  ------------------------------------------------------------------------------
  91.  
  92.  
  93.    MODIFICATION OF ENVIRONMENT SIZE (DOS 2.X - 3.0)
  94.  
  95.    The following DEBUG commands describe the patching of COMMAND.COM in MS-DOS
  96.    and IBM-PC-DOS versions 2.00 through 3.00, located in a diskette mounted in
  97.    drive A:
  98.  
  99.    1. Load: 'DEBUG A:\COMMAND.COM'
  100.  
  101.    2. Search for the code which sets size: 's 100 L 5600 BB 0A 00 B4 48 CD 21'
  102.       This code disassembles to:
  103.                                     MOV  BX,000A   ;environment in paragraphs
  104.                                     MOV  AH,48     ;fn. allocate memory block
  105.                                     INT  21        ;DOS services interrupt
  106.  
  107.    3. DEBUG will then display this code address, which will be 'xxxx:0ECE' for
  108.       MS-DOS versions 2.0 and 2.1, and 'xxxx:0F20' for version 3.0; 'xxxx' may
  109.       be any hexadecimal number.  (If you obtain a different address, use that
  110.       one instead.)
  111.  
  112.    4. Add 1 to this address to get the address of two bytes that determine the
  113.       environment size (0+1=1...8+1=9, 9+1=A, A+1=B...E+1=F, F+1=10 etc), i.e.
  114.       the '0A 00' in item 2.  These two bytes represent the hexadecimal number
  115.       '000A' (corresponding to the decimal number '0010'), which specifies the
  116.       size of the environment in paragraphs (blocks of 16 bytes). Thus, 10x16=
  117.       160 bytes, which is the default size.
  118.  
  119.         NOTE: The bytes of this hexadecimal number are reversed in order, with
  120.               the least significant byte ('0A') listed first, and the most one
  121.               ('00') listed second. This is due to the way the "little-endian"
  122.               microprocessors used by PC and PC-compatible machines store data
  123.               in memory.
  124.  
  125.       To modify the environment size change this number to a hexadecimal digit
  126.       between 000B (16x11=176 decimal bytes) and 0800 (16x2,048=32,768 decimal
  127.       bytes) that should also be stored in memory in reversed byte order. This
  128.       range can be entered with the DEBUG commands:
  129.  
  130.                    'e 0ECF 0B 00' through 'e 0ECF 08 00' for DOS 2.x
  131.       or                   ~~ ~~                  ~~ ~~
  132.                    'e 0F21 0B 00' through 'e 0F21 08 00' for DOS 3.0
  133.                            ~~ ~~                  ~~ ~~
  134.  
  135.       After patching, write the patch to the COMMAND.COM copy with the command
  136.       'W' and exit DEBUG with the command 'Q'.  The patching should be carried
  137.       out in a copy of COMMAND.COM in a bootable disk(ette) different from the
  138.       copy used to boot the machine.
  139.  
  140.    5. To see is the patch was successful, reboot with the diskette in drive A,
  141.       and test the modified command intepreter.
  142.  
  143.       (When you are satisfied that the patch was successful, copy the modified
  144.       COMMAND.COM to the booting disk, *after* saving the original COMMAND.COM
  145.       in a separate diskette in case of conflicts.)
  146.  
  147.  ------------------------------------------------------------------------------
  148.  [END]
  149.